package com.itestor.iptv.modules.common.actions;

import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import com.itestor.iptv.global.actions.AbstractPagedQueryAction;
import com.itestor.iptv.global.bean.AbstractPagedQuery;
import com.itestor.iptv.modules.common.bean.RoleGroupQuery;
import com.itestor.iptv.modules.common.service.RoleGroupService;
import com.itestor.iptv.modules.common.utils.CommonConstant;

/**
 * 
 * @author Mr.li
 * 
 */
public class RoleGroupQueryAction extends AbstractPagedQueryAction {

    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger
            .getLogger(RoleGroupQueryAction.class);

    private RoleGroupService roleGroupService;

    @SuppressWarnings("unchecked")
    @Override   
    public AbstractPagedQuery doPagedQuery(ActionForm form,
            HttpServletRequest request, int pagerCount, int pagerOffset)
            throws Exception {
        String queryRoleGroupName = request.getParameter("queryRoleGroupName");

        RoleGroupQuery roleGroupQuery = new RoleGroupQuery();
        
        roleGroupQuery.setPagerCount(pagerCount);
        roleGroupQuery.setPagerOffset(pagerOffset);
        
        if (!StringUtils.isEmpty(queryRoleGroupName)) {
            roleGroupQuery.setRoleGroupName(queryRoleGroupName);
        }
        
        roleGroupService.queryRoleGroupList(roleGroupQuery);
        
        request.setAttribute(CommonConstant.REQUEST_ATTR_Q_GROUP, roleGroupQuery);
        
        request.setAttribute("queryRoleGroupName", queryRoleGroupName);        
        return roleGroupQuery;
    }

    /**
     * 
     * @param pRoleGroupService
     */
    public void setRoleGroupService(RoleGroupService pRoleGroupService) {
        roleGroupService = pRoleGroupService;
    }

    

}